<!DOCTYPE html>
<html lang="zh-CN">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title>我的订单</title>
        <!-- Bootstrap -->
        <link href="__PUBLIC__/h-ui/yuyue/bootstrap/css/bootstrap.min.css" rel="stylesheet">
        <link href="__PUBLIC__/h-ui/yuyue/css/base.css" rel="stylesheet">
    </head>
    <body>
        <header class="header text-center" style="display: none;">
            <div class="zindex">
                <a href="javascript:;" onclick="javascript :history.back(-1);" class="back">
                    <img src="__PUBLIC__/h-ui/yuyue/images/back.png">返回
                </a>
                <span>我的订单</span>
            </div>
        </header> 
        <!--外层框-->
        <div class="wrap" style="background-color: #ededed; padding-bottom: 40px;">
            <!--我的订单信息-->
            <div class="list-title">会员信息</div>
            <ul class="orderhead clearfix">
                <li><img src="__PUBLIC__/h-ui/yuyue/images/head.png" class="pull-left">{$uinfo['nickname']}</li>
                <li><img src="__PUBLIC__/h-ui/yuyue/images/car.png" class="pull-left">{$uinfo['card']}</li>
            </ul>
            <div class="list-title">订单信息</div>
            <div class="orderinfo clearfix">
                <?php
                    $images = unserialize(html_entity_decode($info['room_images']));
                ?>
                <img src="__PUBLIC__/upload/{$images[0]}" class="pull-left">
                <div class="infor">
                    <div class="stitle">{$info['room_title']}</div>
                    <div class="txt">起租：6个月</div>
                    <div class="txt">定金：<span>￥{$total}</span></div>
                </div>
            </div>
            <ul class="pay-type mt15">
                <li class="clearfix">  
                    <img src="__PUBLIC__/h-ui/yuyue/images/zfb.png" class="pull-left">
                    <div class="center">
                        <div class="name">支付宝支付</div>
                        <span>限有支付宝账户的用户使用</span>
                        <input type="radio" name="type" class="pull-right ckradio" value="alipay" />
                    </div>
                </li>
                <li class="clearfix" style="margin-top:5px;">
                    <img src="__PUBLIC__/h-ui/yuyue/images/wx.png" class="pull-left">
                    <div class="center">
                        <div class="name">微信支付</div>
                        <span>限有微信账户使用</span>
                        <input type="radio" name="type" class="pull-right ckradio" value="weixin" checked />
                    </div>                    
                </li>               
            </ul>
            <!--
            <div class="clearfix xieyi">
                <input type="radio" class="pull-left">我同意《嘛嘛公寓支付协议》
            </div>
            -->
			<input type="hidden" name="room_type" id="room_type" value="{$info['room_type']}" />
        </div>
        <div class="fix" style="padding: 0 10px; margin-bottom: 10px;"><button class="btnpay">确认支付￥{$total}</button></div>
        
        <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
        <script type="text/javascript" src="__PUBLIC__/h-ui/lib/jquery/1.9.1/jquery.min.js"></script>
        <script type="text/javascript" src="__PUBLIC__/h-ui/lib/layer/2.4/layer.js"></script>
        <!-- Include all compiled plugins (below), or include individual files as needed -->
        <script src="__PUBLIC__/h-ui/yuyue/bootstrap/js/bootstrap.min.js"></script>
    </body>
    <script type="text/javascript">
        //判断浏览器
        function isWeiXin(){ 
            var ua = window.navigator.userAgent.toLowerCase(); 
            if(ua.match(/MicroMessenger/i) == 'micromessenger'){ 
                return true; 
            }else{ 
                return false; 
            } 
        }

        //提交支付
        $(".btnpay").on('click', function(){
			var room_type = $("#room_type").val();
			if(room_type.length <= 0){
				layer.msg('房间类型错误', {icon: 5, time: 3000});
				return false;
			}
			
			$.post('order.html', {room_type: room_type}, function(row){
				if(row/1){
					var paymethod = $("input[name='type']:checked").val();
					if(paymethod == 'alipay'){
						if(!isWeiXin()){
							window.location.href = "http://mamagy.com/xj/yuyue/alipay.html?oid="+ row;
						}else{
							layer.msg('请在右上角选择——外部浏览器中打开', {icon: 5, time: 3000});
						}
					}else{
						if(!isWeiXin()){
							layer.msg('请在微信浏览器中打开', {icon: 5, time: 3000});
						}else{
							window.location.href = "http://mamagy.com/xj/wap/weixinpay.html?oid="+ row + '&ptye=yuyue';
						}
					}
				}else{
					layer.msg('创建订单失败', {icon: 5, time: 3000});
					return false;
				}
			});
        });
    </script>
</html>
